<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="lib/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="lib/admin/admin.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看</a>
<!--    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
</script>
<fieldset class="layui-elem-field layui-field-title">
    <legend>验货管理</legend>
</fieldset>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <form class="layui-form" action="">
                    <div class="layui-inline">
                        <label class="layui-form-label">货验收单</label>
                        <div class="layui-input-inline" style="margin-right: 10px">
                            <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入您想搜索的货验收单" id="deliveryOrderCode" class="layui-input" style="width: 250px">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button" class="layui-btn" data-type="reload"  onclick="selectDO()">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            <!--                     layuiadmin-btn-list       lay-submit  lay-filter="LAY-app-contlist-search"-->
                        </button>
                    </div>
                </form>

                <div class="layui-card-body">
<!--                    <button type="button" class="layui-btn" onclick="insertDelivery()">批量确认收货</button>-->
                    <table class="layui-hide" id="test" lay-filter="test"></table>
                </div>
            </div>
        </div>
    </div>
</div>


<table>
</table>


<script src="lib/jquery-1.12.4.js"></script>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use('table', function(){
        var table = layui.table;

        //监听行工具事件
        table.render({
            elem: '#test'
            ,url:'pk/deliveryOrder/listDeliveryOrder'
            ,where :{
                status : 1
            }
            ,parseData: function(res) { //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "msg": "", //解析提示文本
                    "count": 1, //解析数据长度
                    "data": res.obj.list //解析数据列表
                };
            }
            ,page:true
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [[
                {type:'checkbox'}
                ,{field:'deliveryOrderCode', title: '货验收单号', sort: true}
                ,{field:'purchaseOrderCode',title: '上游单号', sort: true}
                ,{field:'supplierName', title: '供应商名称', sort: true}
                ,{field:'statusName', title: '状态', sort: true}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
            ]]
        });
        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                var layer = layui.layer;
                window.deliveryOrderId = data.id;
                showDelivery();
            }
        });
    });

    function selectDO() {
        layui.use('table',function () {
            var deliveryOrderCode = $("#deliveryOrderCode").val();
            var table = layui.table;
            table.reload('test',{
                page : {
                    curr :1
                },where :{
                    deliveryOrderCode : deliveryOrderCode
                }
            })
        })
    }

    function showDelivery() {
        var layer = layui.layer;
        layer.open({
            type: 2,
            area: ['600px','380px'],
            content: 'delivery_inspection_detail.html' //这里content是一个普通的String
        });
    }

</script>
</body>
</html>